package zen_group.mdl;

import java.io.File;
import javax.swing.filechooser.FileFilter;

public class XlsFileFilter
        extends FileFilter
{
    public boolean
    accept(File file)
    {
        if (file.isDirectory())
            return true;

        return getExtension(file).equals("xls");
    }

    public String
    getDescription()
    {
        return "Excel files only";
    }

    private String
    getExtension(File file)
    {
        String name = file.getName();
        int i = name.lastIndexOf('.');

        if (i > 0 && i < name.length() - 1)
            return name.substring(i + 1).toLowerCase();

        return "";
    }
}
